package com.ry.est.dto;

import lombok.Data;

import java.util.List;

/**
 * 通用分页结果对象
 */

@Data
public class PageResult<T> {
    private Integer pageNo;
    private Integer pageSize;
    private Integer total;
    private Integer pages;
    private List<T> list;

    public PageResult(Integer pageSize,Integer total){
        this.pageSize = pageSize;
        this.total = total;
    }


    public Integer getPages(){
        Integer total = getTotal();
        Integer pageSize = getPageSize();

        if (total % pageSize == 0){
            return total / pageSize;
        }else{
            return total / pageSize + 1;
        }
    }
}
